package com.xzy.domain.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * User文档对应的实体
 *
 * @author xzy
 * @date 2021/11/1016:57
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Document(collection = "user") // 指定Java实体与Mongo集合的映射关系
public class UserEntity {
    @Id
    private String id;

    @Field
    @Indexed // 创建索引
    private String name;

    @Field
    private Integer age;

    @Field
    private String sex;

    @Field
    private String phone;

    @Field
    private String email;

    @Field
    private String remark;

    @CreatedDate
    private Date createDate;
}
